package info.pello.greet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class SignUp
 */
@WebServlet("/SignUp")
public class SignUp extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SignUp() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter output = response.getWriter();
		String Login= request.getParameter("Login");
		String Password= request.getParameter("Password");
		//El system.out.println sale en a consola, no en la pagina
			String description=  request.getParameter("Description");
			
			String country= request.getParameter("Country");
			//a la hora de recoger multiples valores se utiliza: request.getParameterValues(var)  lo cual devuelve un array de strings
			String weapons[]= request.getParameterValues("Weapons");
			output.write("Welcome hero of!!"+ country +"</br>");
			output.write("Your name is: "+ Login+ "</br>");
			output.write("And your magic word: "+Password +"</br>");
			if (description != "") {
				output.write("The legend says you are: "+ description + "</br>");
			}
			
			output.write("You have chosen the next weapons: </br>");
			for (int i=0; i< weapons.length ;i++){
				output.write(weapons[i]+"<br />");
			}
		
	}

}
